


/*
'===============================================================================
'  HNG.Portal.BL.TblSanPhamPhuKienManagerBase
'===============================================================================
*/

using System;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using HNG.Portal.BLL;
using HNG.Portal.DAL;
using HNG.Portal.DAL.EntityClasses;
using HNG.Portal.DAL.FactoryClasses;
using HNG.Portal.DAL.HelperClasses;
using SD.LLBLGen.Pro.ORMSupportClasses;
using System.Windows.Forms;
namespace HNG.Portal.BLL
{
	public class TblSanPhamPhuKienManagerBase
	{
	    
		#region ColumnNames
		
				public const String Field_Id="Id";
				
				public const String Field_LangId="LangId";
				
				public const String Field_DanhMucSanPhamId="DanhMucSanPhamId";
				
				public const String Field_SanPhamId="SanPhamId";
				
				public const String Field_TenPhuKien="TenPhuKien";
				
				public const String Field_GiaBan="GiaBan";
				
				public const String Field_SoLuong="SoLuong";
				
				public const String Field_SuDungGia="SuDungGia";
				
				public const String Field_TrangThai="TrangThai";
				
		#endregion	
		/// <summary>
		/// Purpose: Class constructor.
		/// </summary>
		public TblSanPhamPhuKienManagerBase()
		{
			// Nothing for now.
		}
		public DataTable Clone()
		{
			DataTable dt = new DataTable();
						
			
			dt.Columns.Add(Field_Id,typeof(int));
			
						
			
			dt.Columns.Add(Field_LangId,typeof(string));
			
						
			
			dt.Columns.Add(Field_DanhMucSanPhamId,typeof(int));
			
						
			
			dt.Columns.Add(Field_SanPhamId,typeof(int));
			
						
			
			dt.Columns.Add(Field_TenPhuKien,typeof(string));
			
						
			
			dt.Columns.Add(Field_GiaBan,typeof(double));
			
						
			
			dt.Columns.Add(Field_SoLuong,typeof(int));
			
						
			
			dt.Columns.Add(Field_SuDungGia,typeof(bool));
			
						
			
			dt.Columns.Add(Field_TrangThai,typeof(bool));
			
			            
            return dt;			
		}
			
		public TblSanPhamPhuKienEntity Convert_Entity(TblSanPhamPhuKienEntity _TblSanPhamPhuKienEntity,TblSanPhamPhuKienEntity _TblSanPhamPhuKienEntity_XML)
		{	
			
				
			_TblSanPhamPhuKienEntity.Id= _TblSanPhamPhuKienEntity_XML.Id;
				
			_TblSanPhamPhuKienEntity.LangId= _TblSanPhamPhuKienEntity_XML.LangId;
				
			_TblSanPhamPhuKienEntity.DanhMucSanPhamId= _TblSanPhamPhuKienEntity_XML.DanhMucSanPhamId;
				
			_TblSanPhamPhuKienEntity.SanPhamId= _TblSanPhamPhuKienEntity_XML.SanPhamId;
				
			_TblSanPhamPhuKienEntity.TenPhuKien= _TblSanPhamPhuKienEntity_XML.TenPhuKien;
				
			_TblSanPhamPhuKienEntity.GiaBan= _TblSanPhamPhuKienEntity_XML.GiaBan;
				
			_TblSanPhamPhuKienEntity.SoLuong= _TblSanPhamPhuKienEntity_XML.SoLuong;
				
			_TblSanPhamPhuKienEntity.SuDungGia= _TblSanPhamPhuKienEntity_XML.SuDungGia;
				
			_TblSanPhamPhuKienEntity.TrangThai= _TblSanPhamPhuKienEntity_XML.TrangThai;
				
			
			return _TblSanPhamPhuKienEntity;
		}	
		
			
		public void InsertCollection(EntityCollection _Collection)
		{
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
            {
                adapter.SaveEntityCollection(_Collection);
            }
		}

		public TblSanPhamPhuKienEntity Insert(TblSanPhamPhuKienEntity TblSanPhamPhuKienEntity)
		{
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.SaveEntity(TblSanPhamPhuKienEntity, true);
			}
			return TblSanPhamPhuKienEntity;
		}

		
		public TblSanPhamPhuKienEntity Insert(int Id, string LangId, int DanhMucSanPhamId, int SanPhamId, string TenPhuKien, double GiaBan, int SoLuong, bool SuDungGia, bool TrangThai)
		{
			TblSanPhamPhuKienEntity _TblSanPhamPhuKienEntity = new TblSanPhamPhuKienEntity();
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				
				_TblSanPhamPhuKienEntity.Id = Id;
				_TblSanPhamPhuKienEntity.LangId = LangId;
				_TblSanPhamPhuKienEntity.DanhMucSanPhamId = DanhMucSanPhamId;
				_TblSanPhamPhuKienEntity.SanPhamId = SanPhamId;
				_TblSanPhamPhuKienEntity.TenPhuKien = TenPhuKien;
				_TblSanPhamPhuKienEntity.GiaBan = GiaBan;
				_TblSanPhamPhuKienEntity.SoLuong = SoLuong;
				_TblSanPhamPhuKienEntity.SuDungGia = SuDungGia;
				_TblSanPhamPhuKienEntity.TrangThai = TrangThai;
				adapter.SaveEntity(_TblSanPhamPhuKienEntity, true);
			}
			return _TblSanPhamPhuKienEntity;
		}

		public TblSanPhamPhuKienEntity Insert(string LangId, int DanhMucSanPhamId, int SanPhamId, string TenPhuKien, double GiaBan, int SoLuong, bool SuDungGia, bool TrangThai)
		{
			TblSanPhamPhuKienEntity _TblSanPhamPhuKienEntity = new TblSanPhamPhuKienEntity();
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				
				_TblSanPhamPhuKienEntity.LangId = LangId;
				_TblSanPhamPhuKienEntity.DanhMucSanPhamId = DanhMucSanPhamId;
				_TblSanPhamPhuKienEntity.SanPhamId = SanPhamId;
				_TblSanPhamPhuKienEntity.TenPhuKien = TenPhuKien;
				_TblSanPhamPhuKienEntity.GiaBan = GiaBan;
				_TblSanPhamPhuKienEntity.SoLuong = SoLuong;
				_TblSanPhamPhuKienEntity.SuDungGia = SuDungGia;
				_TblSanPhamPhuKienEntity.TrangThai = TrangThai;
				adapter.SaveEntity(_TblSanPhamPhuKienEntity, true);
			}
			return _TblSanPhamPhuKienEntity;
		}

		public bool Update(TblSanPhamPhuKienEntity _TblSanPhamPhuKienEntity)
		{
			bool toReturn = false;
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				RelationPredicateBucket filter = new RelationPredicateBucket();
				IPredicateExpression _PredicateExpression = new PredicateExpression();
				_PredicateExpression.Add(TblSanPhamPhuKienFields.Id == _TblSanPhamPhuKienEntity.Id);
					
				filter.PredicateExpression.Add(_PredicateExpression);

				adapter.UpdateEntitiesDirectly(_TblSanPhamPhuKienEntity, filter);
				toReturn = true;
			}
			return toReturn;
		}
		
		public bool Update(TblSanPhamPhuKienEntity _TblSanPhamPhuKienEntity, RelationPredicateBucket filter)
		{
			bool toReturn = false;
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.UpdateEntitiesDirectly(_TblSanPhamPhuKienEntity, filter);
				toReturn = true;
			}
			return toReturn;
		}

		public bool Update(int Id, string LangId, int DanhMucSanPhamId, int SanPhamId, string TenPhuKien, double GiaBan, int SoLuong, bool SuDungGia, bool TrangThai)
		{
			bool toReturn = false;
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				TblSanPhamPhuKienEntity _TblSanPhamPhuKienEntity = new TblSanPhamPhuKienEntity(Id);
				if (adapter.FetchEntity(_TblSanPhamPhuKienEntity))
				{
				
					_TblSanPhamPhuKienEntity.LangId = LangId;
					_TblSanPhamPhuKienEntity.DanhMucSanPhamId = DanhMucSanPhamId;
					_TblSanPhamPhuKienEntity.SanPhamId = SanPhamId;
					_TblSanPhamPhuKienEntity.TenPhuKien = TenPhuKien;
					_TblSanPhamPhuKienEntity.GiaBan = GiaBan;
					_TblSanPhamPhuKienEntity.SoLuong = SoLuong;
					_TblSanPhamPhuKienEntity.SuDungGia = SuDungGia;
					_TblSanPhamPhuKienEntity.TrangThai = TrangThai;
					adapter.SaveEntity(_TblSanPhamPhuKienEntity, true);
					toReturn = true;
				}
			}
			return toReturn;
		}

		public bool Delete(int Id)
		{
			bool toReturn = false;
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				TblSanPhamPhuKienEntity _TblSanPhamPhuKienEntity = new TblSanPhamPhuKienEntity(Id);
				if (adapter.FetchEntity(_TblSanPhamPhuKienEntity))
				{
					adapter.DeleteEntity(_TblSanPhamPhuKienEntity);
					toReturn = true;
				}
			}
			return toReturn;
		}
		
		public void DeleteAll() 
		{
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.DeleteEntitiesDirectly("TblSanPhamPhuKienEntity", null);
			}
		}
		
		
		public int DeleteById(int Id)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamPhuKienFields.Id == Id);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblSanPhamPhuKienEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByLangId(string LangId)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamPhuKienFields.LangId == LangId);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblSanPhamPhuKienEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByDanhMucSanPhamId(int DanhMucSanPhamId)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamPhuKienFields.DanhMucSanPhamId == DanhMucSanPhamId);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblSanPhamPhuKienEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteBySanPhamId(int SanPhamId)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamPhuKienFields.SanPhamId == SanPhamId);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblSanPhamPhuKienEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByTenPhuKien(string TenPhuKien)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamPhuKienFields.TenPhuKien == TenPhuKien);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblSanPhamPhuKienEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByGiaBan(double GiaBan)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamPhuKienFields.GiaBan == GiaBan);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblSanPhamPhuKienEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteBySoLuong(int SoLuong)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamPhuKienFields.SoLuong == SoLuong);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblSanPhamPhuKienEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteBySuDungGia(bool SuDungGia)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamPhuKienFields.SuDungGia == SuDungGia);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblSanPhamPhuKienEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByTrangThai(bool TrangThai)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamPhuKienFields.TrangThai == TrangThai);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblSanPhamPhuKienEntity", filter);
			}
			return toReturn;
		}
		

		
		public TblSanPhamPhuKienEntity SelectOne(int Id)
		{
			TblSanPhamPhuKienEntity toReturn = null;
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				TblSanPhamPhuKienEntity _TblSanPhamPhuKienEntity = new TblSanPhamPhuKienEntity(Id);
				if (adapter.FetchEntity(_TblSanPhamPhuKienEntity))
				{
					toReturn = _TblSanPhamPhuKienEntity;
				}
			}
			return toReturn;
		}

		// Return EntityCollection
		public EntityCollection SelectAll()
		{
			EntityCollection _TblSanPhamPhuKienCollection = new EntityCollection( new TblSanPhamPhuKienEntityFactory());
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblSanPhamPhuKienCollection, null, 0, null);
			}
			return _TblSanPhamPhuKienCollection;
		}
		
		// Return DataTable
		public DataTable SelectAllRDT()
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblSanPhamPhuKienCollection = new EntityCollection(new TblSanPhamPhuKienEntityFactory());
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblSanPhamPhuKienCollection.EntityFactoryToUse.CreateFields(), toReturn, null, true);
			}
			return toReturn;
		}

		
		// Return EntityCollection
		public EntityCollection SelectById(int Id)
		{
			EntityCollection _TblSanPhamPhuKienCollection = new EntityCollection(new TblSanPhamPhuKienEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamPhuKienFields.Id == Id);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblSanPhamPhuKienCollection, filter, 0, null);
			}
			return _TblSanPhamPhuKienCollection;
		}
		
		// Return DataTable
		public DataTable SelectByIdRDT(int Id)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblSanPhamPhuKienCollection = new EntityCollection(new TblSanPhamPhuKienEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamPhuKienFields.Id == Id);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblSanPhamPhuKienCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByLangId(string LangId)
		{
			EntityCollection _TblSanPhamPhuKienCollection = new EntityCollection(new TblSanPhamPhuKienEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamPhuKienFields.LangId == LangId);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblSanPhamPhuKienCollection, filter, 0, null);
			}
			return _TblSanPhamPhuKienCollection;
		}
		
		// Return DataTable
		public DataTable SelectByLangIdRDT(string LangId)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblSanPhamPhuKienCollection = new EntityCollection(new TblSanPhamPhuKienEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamPhuKienFields.LangId == LangId);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblSanPhamPhuKienCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByDanhMucSanPhamId(int DanhMucSanPhamId)
		{
			EntityCollection _TblSanPhamPhuKienCollection = new EntityCollection(new TblSanPhamPhuKienEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamPhuKienFields.DanhMucSanPhamId == DanhMucSanPhamId);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblSanPhamPhuKienCollection, filter, 0, null);
			}
			return _TblSanPhamPhuKienCollection;
		}
		
		// Return DataTable
		public DataTable SelectByDanhMucSanPhamIdRDT(int DanhMucSanPhamId)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblSanPhamPhuKienCollection = new EntityCollection(new TblSanPhamPhuKienEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamPhuKienFields.DanhMucSanPhamId == DanhMucSanPhamId);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblSanPhamPhuKienCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectBySanPhamId(int SanPhamId)
		{
			EntityCollection _TblSanPhamPhuKienCollection = new EntityCollection(new TblSanPhamPhuKienEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamPhuKienFields.SanPhamId == SanPhamId);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblSanPhamPhuKienCollection, filter, 0, null);
			}
			return _TblSanPhamPhuKienCollection;
		}
		
		// Return DataTable
		public DataTable SelectBySanPhamIdRDT(int SanPhamId)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblSanPhamPhuKienCollection = new EntityCollection(new TblSanPhamPhuKienEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamPhuKienFields.SanPhamId == SanPhamId);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblSanPhamPhuKienCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByTenPhuKien(string TenPhuKien)
		{
			EntityCollection _TblSanPhamPhuKienCollection = new EntityCollection(new TblSanPhamPhuKienEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamPhuKienFields.TenPhuKien == TenPhuKien);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblSanPhamPhuKienCollection, filter, 0, null);
			}
			return _TblSanPhamPhuKienCollection;
		}
		
		// Return DataTable
		public DataTable SelectByTenPhuKienRDT(string TenPhuKien)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblSanPhamPhuKienCollection = new EntityCollection(new TblSanPhamPhuKienEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamPhuKienFields.TenPhuKien == TenPhuKien);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblSanPhamPhuKienCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByGiaBan(double GiaBan)
		{
			EntityCollection _TblSanPhamPhuKienCollection = new EntityCollection(new TblSanPhamPhuKienEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamPhuKienFields.GiaBan == GiaBan);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblSanPhamPhuKienCollection, filter, 0, null);
			}
			return _TblSanPhamPhuKienCollection;
		}
		
		// Return DataTable
		public DataTable SelectByGiaBanRDT(double GiaBan)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblSanPhamPhuKienCollection = new EntityCollection(new TblSanPhamPhuKienEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamPhuKienFields.GiaBan == GiaBan);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblSanPhamPhuKienCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectBySoLuong(int SoLuong)
		{
			EntityCollection _TblSanPhamPhuKienCollection = new EntityCollection(new TblSanPhamPhuKienEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamPhuKienFields.SoLuong == SoLuong);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblSanPhamPhuKienCollection, filter, 0, null);
			}
			return _TblSanPhamPhuKienCollection;
		}
		
		// Return DataTable
		public DataTable SelectBySoLuongRDT(int SoLuong)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblSanPhamPhuKienCollection = new EntityCollection(new TblSanPhamPhuKienEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamPhuKienFields.SoLuong == SoLuong);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblSanPhamPhuKienCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectBySuDungGia(bool SuDungGia)
		{
			EntityCollection _TblSanPhamPhuKienCollection = new EntityCollection(new TblSanPhamPhuKienEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamPhuKienFields.SuDungGia == SuDungGia);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblSanPhamPhuKienCollection, filter, 0, null);
			}
			return _TblSanPhamPhuKienCollection;
		}
		
		// Return DataTable
		public DataTable SelectBySuDungGiaRDT(bool SuDungGia)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblSanPhamPhuKienCollection = new EntityCollection(new TblSanPhamPhuKienEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamPhuKienFields.SuDungGia == SuDungGia);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblSanPhamPhuKienCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByTrangThai(bool TrangThai)
		{
			EntityCollection _TblSanPhamPhuKienCollection = new EntityCollection(new TblSanPhamPhuKienEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamPhuKienFields.TrangThai == TrangThai);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblSanPhamPhuKienCollection, filter, 0, null);
			}
			return _TblSanPhamPhuKienCollection;
		}
		
		// Return DataTable
		public DataTable SelectByTrangThaiRDT(bool TrangThai)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblSanPhamPhuKienCollection = new EntityCollection(new TblSanPhamPhuKienEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamPhuKienFields.TrangThai == TrangThai);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblSanPhamPhuKienCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		

	}
}
